package io.renren.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.dao.SupplierFoodDao;
import io.renren.dto.FoodDTO;
import io.renren.dto.SupplierFoodDTO;
import io.renren.entity.SupplierFoodEntity;
import io.renren.service.SupplierFoodService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 供应商_食材表
 *
 * @author 翟文闯 619556390@QQ.com
 * @since 1.0.0 2019-11-22
 */
@Service
public class SupplierFoodServiceImpl extends CrudServiceImpl<SupplierFoodDao, SupplierFoodEntity, SupplierFoodDTO> implements SupplierFoodService {

    @Autowired
    private SupplierFoodDao supplierFoodDao;
    @Override
    public QueryWrapper<SupplierFoodEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<SupplierFoodEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id);

        return wrapper;
    }

    @Override
    public List<FoodDTO> selectUnit(long id){
        return supplierFoodDao.selectUnitPrice(id);
    }


}